#ifndef FABRIC_H_
#define FABRIC_H_

#include "include.h"
#include "piece.h"
#include "mask.h"

class Fabric
{
private:
	float width, height;
	int resolution;
	QList<Piece> pieces;
	Mask fabric_mask;
	QList<Piece> solution;
	QList<Mask> masks;
	bool rotations[4], vertical_mirror, horizontal_mirror;
	int used_alghoritm, sort_method;
	
	QList<Piece> sortByArea(bool);
	QList<Piece> sortByWaste(bool);
	void createMasks();
	void heurisResult();
	void optimizedHeurisResult();
	void backResult(QList<Piece>, QList<Mask>, QList<int> &, int &, float &, QList<Piece> &, QList<Piece> &, Mask &, Mask &);
	void depthBackResult(int);
	int bestSelection(Mask, Mask &, Piece &, int &, int &);
	bool bestPlace(Mask, Mask, int &, int &);
	void placePiece(Piece &, Mask, int, bool, bool, int, int);

public:
	Fabric(); 
	Fabric(float, int, QList<Piece>, bool, bool, bool, bool, bool, int, int);
	virtual ~Fabric();

	void setWidth(float);
	void resolveCut();
	void draw(QPainter *, bool, bool, bool);
	float getWidth();
	float getHeight();
	QList<Piece> getSolution();
	float piecesArea();
};

#endif /*FABRIC_H_*/
